//
//  PersonalCenterHeaderView.m
//  Loan
//
//  Created by hejinhui on 2017/11/8.
//  Copyright © 2017年 hejinhui. All rights reserved.
//

#import "PersonalCenterHeaderView.h"

@interface PersonalCenterHeaderView()
@property(nonatomic,strong)UIImageView *avater;
@property(nonatomic,strong)UILabel *nikeNameLabel;

@end

@implementation PersonalCenterHeaderView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
       
        self.backgroundColor = RGB_COLOR(83, 137, 236);
        [self addSubview:self.avater];
        [self addSubview:self.nikeNameLabel];
        [self setUpFrame];
    }
    return self;
}

+(instancetype)showPersonCenterHeaderView
{
    return [[self alloc]init];
}

/*
 头像
 */
-(UIImageView *)avater
{
    
    if (!_avater) {
        
        _avater = [[UIImageView alloc]init];
        _avater.backgroundColor = [UIColor redColor];
    }
    return _avater;
}
/*
 昵称
 */
-(UILabel *)nikeNameLabel
{
    
    if (!_nikeNameLabel) {
        
        _nikeNameLabel = [[UILabel alloc]init];
        _nikeNameLabel.textAlignment = NSTextAlignmentCenter;
        _nikeNameLabel.textColor = [UIColor whiteColor];
        _nikeNameLabel.font = [UIFont systemFontOfSize:14];
        _nikeNameLabel.text = @"王尼玛";
    }
    return _nikeNameLabel;
}
/*
 设置尺寸
 */
-(void)setUpFrame{
    
    //头像
    [self.avater mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self);
        make.top.equalTo(self).offset(10);
        make.height.width.mas_equalTo(80);
        
    }];
    
    KViewRadius(_avater, 40);

    //昵称
    [self.nikeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self.avater);
        make.top.equalTo(self.avater.mas_bottom).offset(10);
    }];
    

}


@end
